package org.infodavid.common.persistence;

import java.util.Map;

import javax.persistence.PersistenceException;

/**
 * The Interface IDatabaseHost.
 */
public interface IDatabaseHost extends IDataObject<Long>, INamed, ICommented {

  /** The IP_ADDRESS property. */
  String IP_ADDRESS = "ipAddress";

  /** The JDBC driver property. */
  String JDBC_DRIVER = "driver";

  /** The SCHEMAS property. */
  String SCHEMAS = "schemas";

  /** The TCP_PORT property. */
  String TCP_PORT = "tcpPort";

  /** The USER property. */
  String USERNAME = "username";

  /** The PASSWORD property. */
  String PASSWORD = "password";

  /** The constant MAX_LENGTH_IP_ADDRESS. */
  int MAX_LENGTH_IP_ADDRESS = 64;

  /** The constant MAX_LENGTH_JDBC_DRIVER. */
  int MAX_LENGTH_JDBC_DRIVER = 255;

  /** The constant MAX_LENGTH_USERNAME. */
  int MAX_LENGTH_USERNAME = 128;

  /** The constant MAX_LENGTH_PASSWORD. */
  int MAX_LENGTH_PASSWORD = 16;

  /** The DB_HOST. */
  String DB_HOST = "host";

  /** The HOST property. */
  String HOST = "hostname";

  /** The ID. */
  String ID = "hostKey";

  /** The LOCKED property. */
  String LOCKED = "locked";

  /** The constant MAX_LENGTH_DB_HOST. */
  int MAX_LENGTH_HOST_NAME = 64;

  /** The constant MAX_LENGTH_TYPE. */
  int MAX_LENGTH_TYPE = 32;

  /** The NEW_SCHEMA_ALLOWED property. */
  String NEW_SCHEMA_ALLOWED = "newSchemaAllowed";

  /** The TYPE property. */
  String TYPE = "type";

  /**
   * Gets the IP v4 address.
   * @return the address
   */
  String getIpAddress();

  /**
   * Gets the TCP port.
   * @return the port
   */
  Integer getTcpPort();

  /**
   * Sets the IP v4 address.
   * @param value the address
   */
  void setIpAddress(String value);

  /**
   * Sets the TCP port.
   * @param value the port
   */
  void setTcpPort(Integer value);

  /**
   * Gets the schemas.
   * @return the schemas
   */
  Map<String,IDatabaseSchema> getSchemas();

  /**
   * Adds the schema.
   * @param value the value
   */
  void addSchema(IDatabaseSchema value);

  /**
   * Removes the schema.
   * @param value the value
   */
  boolean removeSchema(IDatabaseSchema value);

  /**
   * Gets the JDBC driver.
   * @return the driver
   */
  String getJdbcDriver();

  /**
   * Gets the user.
   * @return the user
   */
  String getUsername();

  /**
   * Gets the password.
   * @return the password
   */
  String getPassword();

  /**
   * Sets the JDBC driver.
   * @param value the driver
   */
  void setJdbcDriver(String value);

  /**
   * Sets the password.
   * @param value the value
   */
  void setPassword(String value);

  /**
   * Gets the connection configuration associated to the system schema of this database host.
   * @return the configuration object or null
   */
  IConnectionConfiguration toConnectionConfiguration() throws PersistenceException;

  /**
   * Gets the host.
   * @return the host
   */
  String getHostname();

  /**
   * Gets the type.
   * @return the type
   */
  String getType();

  /**
   * Gets the flag describing if the host is locked.
   * @return the flag
   */
  boolean isLocked();

  /**
   * Gets the flag describing if a new schema can be added to this host.
   * @return the flag
   */
  boolean isNewSchemaAllowed();

  /**
   * Sets the host.
   * @param value the host
   */
  void setHostname(String value);

  /**
   * Sets the flag describing if the host is locked.
   * @param flag the flag
   */
  void setLocked(boolean flag);

  /**
   * Sets the flag describing if a new schema can be added to this host.
   * @param flag the flag
   */
  void setNewSchemaAllowed(boolean flag);

  /**
   * Sets the type.
   * @param value the type
   */
  void setType(String value);

  /**
   * Gets the user.
   * @param value the value
   */
  void setUsername(String value);
}
